<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            --width: 20px;
            width: var(--width);
            height: var(--width);
            border: 2px solid #0e84ec;
            position: relative;
            margin: 20px auto;
        }
        #checkbox {
            position: absolute;
            top: 0;
            left: 0;
            z-index: 2;
            margin: 0;
            width: var(--width);
            height: var(--width);
            opacity: 0;
            cursor: pointer;
            /* display: none; */
        }
        .box .content{
            position: relative;
        }
        .box .content::before,
        .box .content::after{
            position: absolute;
            content: "";
            width: var(--width);
            height: 2px;
            background-color: red;
            /* transform-origin: center center; */
            transform: rotate(45deg) translate(6px, 6px) scale(0);
            transition: 0.5s;
        }
        .box .content::after {
            transform: rotate(-45deg) translate(-6px, 6px) scale(0);
        }
        input[type="checkbox"]:checked~.content::before {
            transform: rotate(45deg) translate(6px, 16px);
        }
        input[type="checkbox"]:checked~.content::after {
            width: calc(var(--width)*2);
            transform: rotate(300deg) translate(-5px, 2px);
        }

    </style>
</head>
<body>
    <div class="box">
        <label>
            <input type="checkbox" id="checkbox">
            <div class="content"></div>
        </label>
    </div>
</body>
</html>